package services;

import java.util.List;

/**
 * An exception indicating that a requested service was not found.
 * 
 * @author Henrik Wall
 * @author Rudolf Schmidt
 * @author Eugen Nemirowski
 */
public class NoServiceFoundException extends RuntimeException {

	private static final long serialVersionUID = -7581706766978090240L;
	private static final String MESSAGE = "No service found for operation \"%2$s\" with arguments %1$s and return type %3$s!";

	/**
	 * Constructor for {@link NoServiceFoundException}.
	 * 
	 * @param actualParameters
	 *            the actual parameters for the operation
	 * @param operationName
	 *            the name of the requested operation
	 * @param returnType
	 *            the expected return type
	 * @param cause
	 *            the cause (which is saved for later retrieval by the
	 *            {@link #getCause()} method). (A <tt>null</tt> value is
	 *            permitted, and indicates that the cause is nonexistent or
	 *            unknown.)
	 */
	public NoServiceFoundException(List<?> actualParameters, String operationName, Class<?> returnType, Throwable cause) {
		super(String.format(MESSAGE, actualParameters, operationName, returnType.getName()), cause);
	}

	/**
	 * Constructor for {@link NoServiceFoundException}.
	 * 
	 * @param actualParameters
	 *            the actual parameters for the operation
	 * @param operationName
	 *            the name of the requested operation
	 * @param returnType
	 *            the expected return type
	 */
	public NoServiceFoundException(List<?> actualParameters, String operationName, Class<?> returnType) {
		this(actualParameters, operationName, returnType, null);
	}
}
